package com.example.demo.dao;
//import cn.kingstone.mybatisannotation.entity.User;
import org.apache.ibatis.annotations.*;
import java.util.List;
import com.example.demo.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
@Mapper
public interface UserMapper {

    @Results(id = "usermad",value = {
            @Result(column = "username", property = "name"),
            @Result(column = "password", property = "password"),
            @Result(column = "sex", property = "sex")
    })


    @Insert("insert into user(username, password, sex) values( #{name}, #{password}, #{sex})")//插入名字和密码和性别
    int createUser(User user);
    @Select("select count(1) from user where username =#{username}")
    int findUserByName(User username);

    @Select("select * from user where username =#{username} and password=#{password}")//查询名字和密码
    User getUserByName(@Param("username") String username, @Param("password") String password);

    @Insert("insert into user(id, username, password,sex, phone, qq) values(#{id}, #{username},#{password},#{sex}, #{phone}, #{qq})")
    int create(User user);

    @Select("SELECT * FROM user WHERE username = #{username}")//查询名称
    List<User> getUserByName1(@Param("username") String username);

    @Select("select *from user where id=#{id}")//查询id
    User getUserById(int id);

    @Delete("delete from user where id=#{id}")// 删除id
    int deleteById(int id);

    @Select("select *from user")//查询所有
    List<User> getAllUser();

    @Update("update user set id=#{id},username=#{username},sex=#{sex},phone=#{phone},qq=#{qq} where id=#{id}")
    int updateUser(User user);


    boolean findUserByName(int username);


}
